<?php
require_once 'config21.php';
if (isset($_POST['submit'])) {
    header("Location: login21.php");
    exit();
}

// 查询所有国家鸟类信息
$sql = "SELECT * FROM nationalbird";
$result = $conn->query($sql);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>国家鸟类列表</title>
    <link rel="stylesheet" href="style21.css">
</head>
<body>
    <header>
        <h1>国家鸟类列表</h1>
    </header>
    <nav>
        <a href="index.php">首页</a>
        <a href="list_nationalbird21.php">国家鸟类列表</a>
        <a href="list_introduce21.php">鸟类介绍列表</a>
        <a href="logout21.php">退出登录</a>
    </nav>
    <div class="container">
        <a href="add_nationalbird21.php">添加国家鸟类信息</a>
        <table>
            <tr>
                <th>编号</th>
                <th>国家(英文)</th>
                <th>国家(中文)</th>
                <th>鸟类名称(英文)</th>
                <th>鸟类名称(中文)</th>
                <th>图片路径</th>
                <th>添加时间</th>
                <th>操作</th>
            </tr>
            <?php
            if ($result->num_rows > 0) {
                while ($row = $result->fetch_assoc()) {
                    echo "<tr>";
                    echo "<td>". $row['no']. "</td>";
                    echo "<td>". $row['country']. "</td>";
                    echo "<td>". $row['ccountry']. "</td>";
                    echo "<td><a href='list_introduce50.php?no=". $row['no']. "'>". $row['name']. "</a></td>";
                    echo "<td>". $row['cname']. "</td>";
                    echo "<td><img src='". $row['picture']. "' alt='". $row['cname']. "' style='max-width: 100px; max-height: 100px;'></td>";
                    echo "<td>". $row['addtime']. "</td>";
                    echo "<td>";
                    echo "<a href='edit_nationalbird21.php?id=". $row['no']. "'>编辑</a> | ";
                    echo "<a href='delete_nationalbird21.php?id=". $row['no']. "'>删除</a>";
                    echo "</td>";
                    echo "</tr>";
                }
            } else {
                echo "<tr><td colspan='8'>暂无数据</td></tr>";
            }
?>
        </table>
    </div>
</body>
</html>